# from numpy import *

# a, b = 0, 3


# def f(x):
#     return cos(exp(x)) ** 2


# def trape(n):
#     h = (b - a) / n
#     x = a
#     sum = 0
#     for i in range(1, n):
#         x2 = a + i * h
#         sum = sum + (f(x) + f(x2)) * h / 2
#         x = x2
#     return sum

import numpy as np

a, b = 0, 3


def f(x):
    return np.cos(np.exp(x)) ** 2


def trape(n):
    h = (b - a) / n
    x = a + np.arange(1, n) * h
    y = (f(x) + f(x + h)) * h / 2
    sums = sum(y)

    return sums


# print(trape(10))
# print(trape(100))
# print(trape(1000))
# print(trape(10000))
print(trape(10000000))
